Index
The Index reference form specifies an object or a location by describing its position with respect to the beginning or end of a container.SYNTAX
className [ index ] integer integer(st | nd | rd | th ) className ( first | second | third | fourth | fifth | sixth | seventh | eighth | ninth | tenth ) className ( last | front | back ) classNamewhereclassName is the class identifier of the object being specified.
integer is an integer that describes the position of the object in relation to the beginning of the container (if integer is a positive integer) or the end of the container (if integer is a negative integer).
The forms
first
,second
, and so on are equivalent to the corresponding integer forms (for example,second word
is equivalent toword 2
). For objects whose index is greater than 10, you can use the forms12th
,23rd
,101st
, etc. (Note that any integer followed by any of the suffixes listed is valid; for example, you can use11rd
to refer to the eleventh object.)The
front
form (for example,front window
) is equivalent to className1
orfirst className
. Thelast
andback
forms (for example,last word
andback window
) refer to the last object in a container. They are equivalent to className-1
.The following forms refer to insertion points and are used to specify locations:
beginning | front end | backThebeginning
andfront
forms are equivalent and refer to the first insertion point of the container (insertion point 1
). Theend
andback
forms are equivalent and refer to the last insertion point of the container (insertion point -1
).EXAMPLES
The following references specify the second word from the beginning of the third paragraph.
word 2 of paragraph 3 2nd word of paragraph 3 second word of paragraph 3The following references specify the last word in the third paragraph.
word -1 of paragraph 3 last word of paragraph 3The following reference specifies the next-to-last word in the third paragraph.
word -2 of paragraph 3The following references refer to the first insertion point of the document called Introduction.
beginning of document "Introduction"front of document "Introduction"The following example contains two references. The first is a reference to the tenth word of the document called Introduction. The second is a reference to the last insertion point in the same document.
tell application "Scriptable Text Editor" move word 10 of document "Introduction" to ÿ end of document "Introduction"end tell